<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="检索" prop="search">
        <el-input v-model="queryParams.search" placeholder="请输入检索信息" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>

      <el-form-item label="选择日期" prop="dateTime">
        <el-date-picker clearable v-model="queryParams.dateTime" type="date" value-format="yyyy-MM-dd" placeholder="选择日期">
        </el-date-picker>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="markList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="招标编码" align="center" prop="markId" width="180" />
      <el-table-column label="招标名" align="center" prop="markName" />
      <el-table-column label="结束时间" align="center" prop="markEnd">
        <template slot-scope="scope">
          <el-tag effect="dark" type="danger">
            {{ parseTime(scope.row.markEnd, '{y}-{m}-{d}') }}
          </el-tag>
        </template>
      </el-table-column>
      <el-table-column label="状态" align="center" prop="firmStatus">
        <template slot-scope="scope">
          <el-tag effect="dark" type="danger" v-if="scope.row.firm == null || scope.row.firmStatus == '0'">
            未报名
          </el-tag>
          <el-tag effect="dark" type="info" v-if="scope.row.firmStatus == '1'">
            已过期
          </el-tag>
          <el-tag effect="dark" type="info" v-if="scope.row.firmStatus == '5'">
            报名成功
          </el-tag>
          <el-tag effect="dark" type="info" v-if="scope.row.firmStatus == '2'">
            待开标
          </el-tag>
          <el-tag effect="dark" type="info" v-if="scope.row.firmStatus == '6'">
            驳回
          </el-tag>

          <el-tag effect="dark" type="info" v-if="scope.row.firmStatus == '4'">
            中标
          </el-tag>

        </template>
      </el-table-column>

      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button v-if="scope.row.firm == null || scope.row.firmStatus == '0'" size="mini" type="text"
            icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['wms:mark:edit']">去报名</el-button>
          <el-button v-else size="mini" type="text" icon="el-icon-edit" @click="Detail(scope.row)"
            v-hasPermi="['wms:mark:edit']">详情</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />


  </div>
</template>

<script>
import { listMarkFirm } from "@/api/wms/firm";
export default {
  name: "Mark",
  data () {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 招标信息发布表格数据
      markList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      // 表单参数
      form: {},

    };
  },
  created () {
    this.getList();
  },
  methods: {
    // 去报名 跳转路由
    handleUpdate (row) {
      this.$router.push({ path: "/task/cloth/list", query: { markId: row.id } });
    },
    // 详情
    Detail (row) {
      this.$router.push({ path: "/task/cloth/list", query: { markId: row.id, firmId: row.firm.id } });
    },
    /** 查询招标信息发布列表 */
    getList () {
      this.loading = true;
      listMarkFirm(this.queryParams).then(response => {
        this.markList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel () {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset () {
      this.form = {

      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery () {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery () {
      this.queryParams = {
        pageNum: 1,
        pageSize: 10,
      },
        this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange (selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },

  }
};
</script>
